import 'package:boss/provider/offers_provider.dart';

import 'package:boss/ui/page/offersManagement/widget/offers_list.dart';
import 'package:boss/ui/widget/center_title_app_bar.dart';
import 'package:boss/ui/widget/custom_tab.dart';
import 'package:boss/ui/widget/label_button.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';
import 'package:router/annotation.dart';

import 'page/plusOffersMode/plus_offers_mode_page.dart';

@RouterConfig(OffersManagementPage.pageName)
class OffersManagementPage extends StatefulWidget {
  static const pageName = '/offersManagementPage';

  const OffersManagementPage({
    Key key,
  }) : super(key: key);

  @override
  _OffersManagementPageState createState() => _OffersManagementPageState('优惠管理');
}

class _OffersManagementPageState extends BaseState<OffersManagementPage> {
  _OffersManagementPageState(String pageName) : super(pageName);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CenterTitleAppBar(
        title: '优惠管理',
        actions: <Widget>[
          LabelButton(
            title: '+新增优惠',
            padding: EdgeInsets.only(left: 8, top: 2, bottom: 2),
            onTap: () {
              Navigator.pushNamed(context, PlusOffersModePage.pageName);
            },
          ),
        ],
      ),
      body: CustomTab(
        tabs: ['进行中', '未开始', '已结束'],
        padding: EdgeInsets.only(
          top: 15.w,
        ),
        isScrollable: false,
        tabViews: <Widget>[
          OffersList(
            status: OffersType.processing,
          ),
          OffersList(
            status: OffersType.noStarted,
          ),
          OffersList(
            status: OffersType.over,
          ),
        ],
      ),
    );
  }
}
